Skip to content

fix(UpdateCard): render Execute when status=completed + x-medkit-phase=prepared#72

Merged
bburda merged 2 commits intomainfrom
fix/update-card-phase-aware-buttons
Apr 23, 2026
Merged

fix(UpdateCard): render Execute when status=completed + x-medkit-phase=prepared#72
bburda merged 2 commits intomainfrom
fix/update-card-phase-aware-buttons

Conversation

@bburda
Copy link
Copy Markdown
Contributor

@bburda bburda commented Apr 22, 2026

Pull Request

Summary

Teach `UpdateCard` that `status=completed` is not always terminal: when the gateway's `x-medkit-phase` vendor extension reports `prepared`, the prepare step finished but execute still needs to run, so the card must offer Execute / Delete rather than only Delete.

  • Add the optional `x-medkit-phase` field to `UpdateStatus`.
  • Pass the full `UpdateStatus` into `actionButtonsForStatus` and branch on the phase inside the `completed` case.
  • Add Vitest coverage for phase-missing (legacy/one-shot plugins), `phase=prepared`, and `phase=executed`.

Behavior for plugins that run the pipeline in one shot (no phase field) is unchanged.


Issue


Type

  • Bug fix
  • New feature
  • Breaking change
  • Documentation only

Testing

  • `npm run lint` passes.
  • `npm run build` passes.
  • `npm test` passes (401 tests), including the three new cases added to `src/components/UpdateCard.test.tsx`.

Manual check: register an update, click Prepare, wait for `status=completed` + `x-medkit-phase=prepared` on `GET /updates/{id}/status`; the card now shows Execute and Delete. After Execute resolves with `x-medkit-phase=executed`, only Delete remains.


Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed) - no breaking changes
  • Linting passes (`npm run lint`)
  • Build succeeds (`npm run build`)
  • Docs were updated if behavior or public API changed - `UpdateStatus` TSDoc updated to describe the new field

SOVD collapses prepare and execute terminal states into status=completed
and keeps the real phase on the vendor extension x-medkit-phase. Plugins
that split the install pipeline (uptane_ota and similar) emit
{ status: 'completed', 'x-medkit-phase': 'prepared' } after prepare -
the install still needs to be triggered. The old actionButtonsForStatus
only branched on status, so prepared updates flashed as fully terminal
and showed only Delete; the Execute button never rendered and users
had no UI path to finish the install.

Add the phase field to the UpdateStatus type and pass the full status
into actionButtonsForStatus. When phase === 'prepared' return
['execute', 'delete']; any other completed update is truly terminal
and keeps the previous ["delete"] behaviour. Existing tests still
pass; add three cases covering phase-missing, phase=prepared, and
phase=executed.
Copilot AI review requested due to automatic review settings April 22, 2026 07:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts UpdateCard behavior to handle split-pipeline OTA plugins where status: "completed" can still require an Execute step when the gateway reports x-medkit-phase: "prepared".

Changes:

  • Extend UpdateStatus with optional x-medkit-phase vendor extension.
  • Update actionButtonsForStatus to branch on x-medkit-phase when status.status === "completed".
  • Add Vitest cases covering missing phase, prepared, and executed.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/lib/types.ts Adds optional x-medkit-phase to UpdateStatus with explanatory TSDoc.
src/components/UpdateCard.tsx Updates action-button selection to show Execute after completed + prepared.
src/components/UpdateCard.test.tsx Adds regression tests for legacy/no-phase and phase-specific completed states.

Comment thread src/components/UpdateCard.tsx
Comment thread src/lib/types.ts
@bburda bburda self-assigned this Apr 22, 2026
Comment thread src/lib/types.ts Outdated
Comment thread src/components/UpdateCard.tsx
Comment thread src/components/UpdateCard.test.tsx
Comment thread src/lib/types.ts Outdated
- Export UpdatePhase union (none/preparing/prepared/executing/executed/
  failed/deleting) matching the gateway `update_phase_to_string` enum
  and use it on UpdateStatus['x-medkit-phase'] instead of `string`. This
  gives compile-time checking for phase comparisons and typos.
- Add a default branch to actionButtonsForStatus so a non-conforming
  status string from a plugin falls back to `['delete']` instead of
  returning undefined and crashing the .map(...) render path.
- Cover the added edge cases in tests: unknown phase on completed
  (falls back to Delete-only) and phase on failed (ignored; retry
  actions still surface).
Copy link
Copy Markdown

@mfaferek93 mfaferek93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bburda bburda merged commit 06ca6fa into main Apr 23, 2026
3 checks passed
@bburda bburda deleted the fix/update-card-phase-aware-buttons branch April 23, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UpdateCard: Execute button never renders for split-pipeline plugins (status=completed + x-medkit-phase=prepared)

3 participants